import Vue from 'vue'
import axios from 'axios'
import App from './App'
import router from './router'
import store from './store'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

import 'xe-utils'
import VXETable from 'vxe-table'
import 'vxe-table/lib/style.css'

import qs from 'qs'

import moment from 'moment'
Vue.prototype.$moment = moment
moment.locale('zh-cn')

if (!process.env.IS_WEB) Vue.use(require('vue-electron'))
Vue.prototype.$axios = axios
Vue.prototype.base = 'http://localhost:7000'
Vue.config.productionTip = false
Vue.use(ElementUI)
Vue.use(VXETable)

// axios.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8'
// 添加响应拦截器
axios.interceptors.request.use(
  config => {
    if (config.method === 'post') {
      config.data = qs.stringify(config.data)
    }
    return config
  },
  error => {
    console.log(error)
    Promise.reject(error)
  }
)

new Vue({
  components: { App },
  router,
  store,
  template: '<App/>'
}).$mount('#app')
